package com.example.administrator.uis.view.paintView

import android.content.Context
import android.graphics.*
import android.util.AttributeSet
import android.view.View
import com.example.administrator.uis.R

/**
 * Created by Administrator on 2017/11/14 0014.
 */
class PracticeXiaoguoView(context: Context?, attrs: AttributeSet?) : View(context, attrs) {
    var paint = Paint(Paint.ANTI_ALIAS_FLAG)

    override fun onDraw(canvas: Canvas?) {
        super.onDraw(canvas)
        paint.strokeWidth = 1f
        var pathEffer = DashPathEffect(floatArrayOf(10f, 5f), 10f)
        paint.setPathEffect(pathEffer)
        canvas?.drawCircle(100f, 100f, 50f, paint)
        paint.style = Paint.Style.STROKE
        paint.strokeWidth = 20f
        canvas?.drawCircle(270f, 100f, 50f, paint)
        paint.strokeCap = Paint.Cap.SQUARE
//        paint.strokeCap=Paint.Cap.BUTT
//        paint.strokeCap=Paint.Cap.ROUND
//        canvas?.drawLine(200f,100f,200f,200f,paint)
        paint.strokeJoin = Paint.Join.MITER
        paint.strokeMiter = 90f
        var dianji = floatArrayOf(200f, 100f, 200f, 200f, 250f, 150f, 200f, 200f)
        canvas?.drawLines(dianji, paint)
        paint.strokeWidth = 10f
        paint.color=Color.GREEN
        paint.setShadowLayer(30f,2f,2f,Color.GRAY)
        var path = Path()
        path.lineTo(100f, 100f)
        path.lineTo(120f, 80f)
        path.lineTo(150f, 120f)
        path.lineTo(270f, 220f)
        path.lineTo(370f, 20f)
        var cornerpath = CornerPathEffect(20f)
        paint.pathEffect = cornerpath
        canvas?.drawPath(path, paint)

    }
}